JavaScript

A5.u.iconhtml Method

Syntax

A5.u.icon.html(icon[,attributes])

Arguments

iconstring

The string defining the icon to create. See A5.u.icon for details on the icon string.

attributesstring

Optional extra attributes to add to the generated icon tag. For example, this can be used to add an ID to the icon.

Returns

htmlstring

The HTML for the icon.

Description

Get the HTML for an icon.

Example

var imgIcon = A5.u.icon.html('icons/error.png','id="icon1" a5-item="error"');
// imgIcon = '<img src="icons/error.png" id="icon1" a5-item="error" />'
var cssIcon = A5.u.icon.html('cssIcon=icon iconError','id="icon2" a5-item="error"');
// cssIcon = '<i class="icon iconError" id="icon2" a5-item="error"></i>'
var svgIcon = A5.u.icon.html('svgIcon=#icon-error:iconErr,24px{fill: red;}','id="icon3" a5-item="error"');
// svgIcon = '<svg class="iconErr" width="24px" height="24px" style="fill: red;" id="icon3" a5-item="error"><use x="0" y="0" width="100%" height="100%" xlink:href="#icon-error" pointer-events="none"/></svg>'